var UID;
function sendRandom() {
	var c = $("#mobile").val();
	if(c==null || c.length<11){
		layer.msg("请输入正确的手机号");
		return ;
	}
	$.ajax({
		url: "GetRegisterCode",
		data: {
			'mobile': c
		},
		type: "post",
		success: function(a) {
			console.log(a);
			var b = JSON.parse(a);
			if(b.result=='success'){
				layer.msg("验证码发送成功,验证码为"+b.code)
				$("#message").val(b.code)
			}else{
				layer.msg("验证码发送失败")
			}
		}
	})
}
function register() {
	var c = $("#mobile").val().replace(/\s+/g, "");
	var d = $("#message").val();
	var e = $("#password").val();
	$.ajax({
		url: "RegisterUser",
		data: {
			'code': d,
			'mobile': c,
			'password': e,
		},
		type: "post",
		success: function(a) {
			console.log(a);
			var b = JSON.parse(a);
			if(b.result=='success'){
				layer.msg("注册成功")
			}else{
				layer.msg("注册失败")
			}
		}
	})
}
function login() {
	var a = $("#appPassword").val();
	var b = $("#desmobile").val();
	$.post("login", {
		'password': a,
		'mobile': b
	}, function(a) {
		console.log(a);
		var b = JSON.parse(a);
		if(b.result=='success'){
			layer.msg("登陆成功");
			UID=b.user.UID;
			joinOutActivity(b.user.UID);
		}else{
			layer.msg("登陆失败");
		}
	})
}
function joinOutActivity(UID) {
	mobile = $("#mobile").val();
	$.get("JoinOutActivity", {
		'UID': UID
	}, function(a) {
		console.log(a);
		var b = JSON.parse(a);
		if(b.result=='success'){
			layer.msg("流量领取成功");
		}else{
			layer.msg("流量领取失败");
		}
	})
}
function getOutActivityMessage(UID) {
	$.get("GetOutActivityMessage", {
		'UID': UID
	}, function(a) {
		console.log(a);
		var b = JSON.parse(a);
		layer.msg("奖品还剩"+b.amount+"份");
	})
}